/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package brutot;

import java.awt.Color;
import java.awt.image.BufferedImage;

/**
 *
 * @author Scar
 */
public class Matriz {
    private int[][][] matriz;
    int ancho;
    int alto;
    Color mcolor[][];
    BufferedImage imagen;
    public Matriz(BufferedImage imagen){
        this.imagen= imagen;
        ancho = imagen.getWidth();
         alto = imagen.getHeight();
        matriz = new int[5][ancho][alto];
          mcolor = new Color[ancho][alto];
         rellenaMatrizColor(mcolor);
         rellenaMov0();
         rellenaMov1();
         rellenaMov2();
         rellenaMov3();
         rellenaMov4();
    }
    public void rellenaMatrizColor(Color[][] mcolor){

     for (int y= 0; y<alto; y++)

         for (int x=0; x<ancho; x++){
             mcolor[x][y]= new Color(imagen.getRGB(x,y));
         }
     }
    public int diferenciaColor(Color c1,Color c2) {

    return ( java.lang.Math.max(c1.getRed(),c2.getRed()) -
             java.lang.Math.min(c1.getRed(),c2.getRed()) +
             java.lang.Math.max(c1.getGreen(),c2.getGreen()) -
             java.lang.Math.min(c1.getGreen(),c2.getGreen()) +
             java.lang.Math.max(c1.getBlue(),c2.getBlue()) -
             java.lang.Math.min(c1.getBlue(),c2.getBlue())
            );
    }
     public void rellenaMov0(){
     for (int y= 1; y<alto; y++)
     {
         for (int x=0; x<ancho-1; x++){
             matriz[0][x][y]= diferenciaColor(mcolor[x][y],mcolor[x+1][y-1]);
         }
     }
     }
     public void rellenaMov1(){
     for (int y= 0; y<alto; y++)
     {
         for (int x=0; x<ancho-1; x++){
             matriz[1][x][y]= diferenciaColor(mcolor[x][y],mcolor[x+1][y]);
         }
     }
     }
   public void rellenaMov2(){
     for (int y= 0; y<alto-1; y++)
     {
         for (int x=0; x<ancho-1; x++){
             matriz[2][x][y]= diferenciaColor(mcolor[x][y],mcolor[x+1][y+1]);
         }
     }
     }
    public void rellenaMov3(){
     for (int y= 0; y<alto-1; y++)
     {
         for (int x=0; x<ancho; x++){
             matriz[3][x][y]= diferenciaColor(mcolor[x][y],mcolor[x][y+1]);
         }
     }
     }
    public void rellenaMov4(){
     for (int y= 0; y<alto-1; y++)
     {
         for (int x=1; x<ancho; x++){
             matriz[4][x][y]= diferenciaColor(mcolor[x][y],mcolor[x-1][y+1]);
         }
     }
     }
     public int retornaContenido(int mov, int col, int fila){
         return matriz[mov][col][fila];

     }
   // public void rellenaEnergiaSuperior



}
